<%@ page isELIgnored="false" %><%--isELIgnored=true禁用EL表达式--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- JSTL标签库是一个JSP标签的集合，封装了许多jsp应用程序通用的核心功能-->
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/layui-v2.6.13/layui/css/layui.css"/>
    <script src="${pageContext.request.contextPath}/js/jquery.min-2.1.1.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/layui-v2.6.13/layui/layui.js"></script>
    <style>
        .layui-form{
            margin-top: 30px;
            margin-left: 30px;
        }
        #d1{
            margin-left: 30px;
        }
    </style>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">账户：</label>
        <div class="layui-input-inline">
            <input type="text" name="mName" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码：</label>
        <div class="layui-input-inline">
            <input type="text" name="mPass" class="layui-input">
        </div>
    </div>
</form>
<div class="layui-form-item" id="d1">
    <div class="layui-input-block">
        <button class="layui-btn" style="width: 150px;" onclick="add()">添加</button>
    </div>
</div>
</body>
<script>
    function add(){
        var params = $("form").serialize();
        console.info(params);
        $.ajax({
            url: "http://localhost:8080/shopping/manager/insertOneManager",
            data: params,
            type: "post",
            success: function(code){
                if(code == '1'){
                    alert("添加成功");
                } else {
                    alert("添加失败");
                }
                //延迟关闭
                setTimeout(closeLayer(), 500);
            }
        });
    }
    function closeLayer(){
        //关闭弹出层
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
        //刷新父页面
        window.parent.location.reload();
    }
</script>
</html>